package com.baixiaowen.disruptor.DisruptorHigh高准操作;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

public class Handler1 implements EventHandler<Trade>, WorkHandler<Trade> {
    // EventHandler
    @Override
    public void onEvent(Trade event, long sequence, boolean endOfBatch) throws Exception {
        this.onEvent(event);
        if (endOfBatch) {
            System.err.println("Handler1 is last one");
        }
    }

    // WorkHandler
    @Override
    public void onEvent(Trade event) throws Exception {
        System.err.println("Handler1 : SET NAME");
        Thread.sleep(1000);
        event.setName("H1");
    }
}
